//
// Created by lingzhitech on 25-11-7.
//

#include <iostream>
#include <string>
using namespace std;

class Base {
public:
    Base() { cout << "Base(): 默认构造函数\n"; }
    Base(int i) { cout << "Base(int): 用参数 " << i << " 构造\n"; }
};

class Derived : public Base {
public:
    Derived() {
        cout << "Derived(): 默认构造函数\n";
    }

    Derived(int i) : Base(i) {  // 🔹 在这里指定调用 Base(int) 构造函数
        cout << "Derived(int): 派生类构造函数\n";
    }
};

int main() {
    cout << "创建 d1:\n";
    Derived d1;        // 会默认调用 Base() → Derived()
    cout << "创建 d2:\n";
    Derived d2(42);    // 会调用 Base(42) → Derived(int)
}
